package cn.com.headfree.base.dao.impl;

import cn.com.headfree.base.dao.SysDictionaryInfoDao;
import cn.com.headfree.entity.TAcadeAchiveInfo;
import cn.com.headfree.entity.TSysDictionaryInfo;
import cn.com.headfree.vo.SysDictionaryInfoVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository("/sysDictionaryInfoDao")
public class SysDictionaryInfoDaoImpl extends BaseDaoImpl<SysDictionaryInfoVo> implements SysDictionaryInfoDao {


    @Override
    public List<SysDictionaryInfoVo> getSysDictionaryInfo(String pId) {
        StringBuilder sqlBuilder = new StringBuilder("select * from t_sys_dictionary_info where p_id=? ");
        sqlBuilder.append(" order by value");
        ArrayList<Object> arrayList = new ArrayList<Object>();
        arrayList.add(pId);
        return this.findAllBySQL(SysDictionaryInfoVo.class, sqlBuilder.toString(), null, false,arrayList.toArray());
    }


    @Override
    public List<TSysDictionaryInfo> getDictionarys(String pvalue){
        String sql = "select id,name,value from t_sys_dictionary_info ";
        StringBuilder sb = new StringBuilder(sql);
        sb.append(" where del_sign=0")
                .append("  and p_id=(select id")
                .append("  from t_sys_dictionary_info")
                .append(" where del_sign=0")
                .append(" and value=?)");
        sb.append(" order by value");

        return this.findAllBySQL(TSysDictionaryInfo.class, sb.toString(), null, false, new Object[] {pvalue});
    }
}
